package myExample;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;

import org.apache.uima.resource.DataResource;
import org.apache.uima.resource.ResourceInitializationException;
import org.apache.uima.resource.SharedResourceObject;

public class StringMapResources implements SharedResourceObject {
	private ArrayList<String> mList = new ArrayList<String>();
	@Override
	public void load(DataResource data) throws ResourceInitializationException {		
		InputStream inStr = null;
	    try {
	      // open input stream to data
	      inStr = data.getInputStream();
	      BufferedReader reader = new BufferedReader(new InputStreamReader(inStr,"UTF-8"));
	      String line;
	      while ((line = reader.readLine()) != null) {	          
	          mList.add(line);
	      }
	    } catch (IOException e) {
	        throw new ResourceInitializationException(e);
	    } finally {
	        if (inStr != null) {
	          try {
	            inStr.close();
	          } catch (IOException e) {
	          }
	        }
	    }
	}
	
	public String getString(int index){
		return mList.get(index);
	}
	
	public int getSizeList(){
		return mList.size();
	}
}
